package com.example.demo.controller;

import java.util.List;

import javax.annotation.Resource;
/*
 * 测试用
 */

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.dto.OrderInfDto;
import com.example.demo.dto.OrderMangeDto;
import com.example.demo.dto.UserMangeDto;
import com.example.demo.dto.VipMangeDto;
import com.example.demo.service.ManageService;
import com.example.demo.service.TestService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
/*
 * 管理页面1
 */
@Controller
@Data
@RequestMapping("/management")
@Api("管理页面")
public class BusinessManagementController {
	@Resource
	private ManageService manageService;
	
	@RequestMapping(value="/order",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "获取所有订单",notes = "返回订单信息,无参数")
	public List<OrderMangeDto> getOrder() {
		List<OrderMangeDto> list=manageService.getAllOrder();
		return list;
	}
	
	@RequestMapping(value="/user",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "获取所有用户",notes = "返回用户信息,无参数")
	public List<UserMangeDto> getUser() {
		List<UserMangeDto> list=manageService.getAllUser();
		return list;
	}
	
	@RequestMapping(value="/delOrder",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "删除订单信息",notes = "返回是否成功,需要传入一个id")
	public String delOrder(int id) {
		String result=manageService.deleteOrder(id);
		return result;
	}
	
	@RequestMapping(value="/delUser",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "删除用户信息",notes = "返回是否成功,需要传入一个id")
	public String delUser(int id) {
		String result=manageService.deleteUser(id);
		return result;
	}
	
	@RequestMapping(value="/vip",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "获取所有VIP",notes = "返回VIP信息")
	public List<VipMangeDto> getVip() {
		List<VipMangeDto> list=manageService.getAllVip();
		return list;
	}
	
	
	@RequestMapping(value="/delVip",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "删除VIP",notes = "返回是否成功,需要传入一个vid")
	public String delVip(int vid) {
		String result=manageService.deleteVip(vid);
		return result;
	}
	
	@RequestMapping(value="/changeVip",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "修改VIP",notes = "返回是否成功")
	public String changeVip(int vid,String vlevel,double vdiscount) {	
		String result=manageService.toChangeVip(vid,vlevel,vdiscount);
		return result;
	}
	
	@RequestMapping(value="/insertVip",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "新增VIP",notes = "返回是否成功,需要传入一个String类型的vlevel字段，和double类型的vdiscount字段")
	public String insertVip(String vlevel,double vdiscount) {	
		String result=manageService.insertVip(vlevel,vdiscount);
		return result;
	}
	
	@RequestMapping(value="/feedback",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "反馈信息提交",notes = "返回是否成功,需要传入一个String类型的title字段，和String类型的text字段")
	public String feedbackInf(String title,String text) {	
		String result=manageService.feedback(title,text);
		System.out.println(result);
		return result;
	}
	
	@RequestMapping(value="/orderInf",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "获取订单详情",notes = "返回订单信息")
	public OrderInfDto orderInf(int oid) {
		OrderInfDto inf=manageService.getOrderInf(oid);
		return inf;
	}
}
	
